package com.itjiange.servlet;

import com.itjiange.modle.Dept;
import com.itjiange.service.DeptService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/all")
public class ListServlet extends HttpServlet {
    private DeptService service = new DeptService();

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        List<Dept> deptList = service.getAllDept();
        System.out.println(deptList);
        //存储内容
        req.setAttribute("depts",deptList);
        req.getRequestDispatcher("/WEB-INF/all.jsp").forward(req,resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        super.doPost(req, resp);
    }
}
